//
//  BulletSprite.cpp
//  airfight
//
//  Created by aaron more on 12-8-29.
//  Copyright (c) 2012年 moonriver. All rights reserved.
//

#include <iostream>
#include "BulletSprite.h"


BulletSprite::BulletSprite()
:m_pType(0)
,m_pDamage(0)
,m_pFrequency(0)
,m_pSpeed(0)
,m_pDuration(0.0)
,m_pAngle(0)
,m_pGroup_num(0)
,m_pGroup_interval(0)
,m_pBegin(0)
,m_pIsUse(0)
{
    m_pFirePoint = CCPointMake(0,0);
}

bool BulletSprite::init()
{
    EntitySprite::init();
    return true;
}

BulletSprite::~BulletSprite()
{
    
}

void BulletSprite::onEnter()
{
    EntitySprite::onEnter();
    batch = (CCSpriteBatchNode*)this->getParent();
    screenSize = CCDirector::sharedDirector()->getWinSize();
    scheduleUpdate();
}

void BulletSprite::handleContact(ENTITY_TYPE type, CCDictionary *effect)
{
    
}

void BulletSprite::update(float dt)
{
    if(this->isVisible())
    {
        //是否可以根据速度属性做scheduleupdate

        CCPoint currPostion = this->getPosition();
        if( currPostion.x < 0 || currPostion.y < 0 || currPostion.x >= screenSize.width || currPostion.y >= screenSize.height )
        {
            if (this->getEntityType() == PLAYER_BULLET) {
                CCNotificationCenter::sharedNotificationCenter()->postNotification(REDRAW_BULLET_OUTBOUND_NOTIFICATION, CCInteger::create(this->getTag()));
            }
                
            
            //CCLog("out");
//            this->setPosition(ccp(0,0));
//            this->stopAllActions();
//            this->setVisible(false);
        }
    }
}

//void Issue1327::logSprRotation(CCNode* pSender)
//{
//    CCLog("%f", ((CCSprite*)pSender)->getRotation());
//}
